package com.dream.util;

import javax.servlet.http.Cookie;

/**
 * @author 匠人码农
 * @date 2020/11/08 8:54
 * 概要：
 *     Cookie的工具类
 */

public class CookieUtil {
    /**
     * 查找cookie
     * @param name 要查找的cookie的名称
     * @param cookies 查找cookie数组
     * @return 返回找到的cookie
     */
    public static Cookie findCookie(String name, Cookie cookies[]) {

        if(null == name || null == cookies || cookies.length == 0){
            return null;
        }
        for(Cookie cookie:cookies){
            if(cookie.getName().equals(name)){
                return cookie;
            }
        }
        return null;
    }
}